# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://doc.scrapy.org/en/latest/topics/item-pipeline.html


class NovelPipeline(object):
    def process_item(self, item, spider):
        novel = '{}.txt'.format(item['name'])
        # 动态创建小说的文件
        self.file = open(novel, 'a',encoding='utf-8')
        self.file.write(item['chapter_title'] + '\n' + item['chapter_content'])
        self.file.close()
